<?php

class FlashMessage
{
	public static function saveInfo(array $info)
	{
		Yii::app()->user->setFlash('status', $info);
	}
	
	public static function getInfo()
	{
		return Yii::app()->user->getFlash('status');
	}
	
	public static function renderFlashInfoHtml()
	{
		$statusData = FlashMessage::getInfo();
		
		$html = '';
		
		if ($statusData) {
			$html  = '<script type="text/javascript">';
			$html .= 'Ext.onReady(function() {';
			$html .= 	'Ext.MessageBox.show({';
	        $html .= 		'title: "' . $statusData['title'] . '",';
	        $html .= 		'msg: "' . $statusData['text'] . '",';
	        $html .= 		'buttons: Ext.MessageBox.OK,';
	        $html .= 		'animEl: "mb9",';
	        $html .= 		"icon: 'ext-mb-info'";
	       	$html .= 	"});";
			$html .= '});';
			$html .= '</script>';
		}
		
		return $html; 
	}
}	